<?php
class models_user extends connect{
	function _listuser()
	{
		$sql = "SELECT MaUser, TenUser, MatKhau, DienThoai, Quyen
				FROM user";
		$this->query_db($sql);
		return $this->fetchAll();
	}
	
	function _addUser($TenUser, $MatKhau, $DienThoai,$Quyen)
	{
		$sql = "INSERT INTO user VALUES('','$TenUser','$MatKhau','$DienThoai','$Quyen')";
		$this->query_db($sql);
		
	}
	
	function _delUser($id){
		$sql = "DELETE 
				FROM user
				WHERE MaUser = '$id'";
		$this->query_db($sql);
	}
	
	function _getUser($id){
		$sql = "SELECT MaUser, TenUser, MatKhau, DienThoai, Quyen
				FROM user
				WHERE MaUser = '$id'";
		$this->query_db($sql);
		return $this->fetchOne();
	}
	
	function _updateUser($TenUser, $MatKhau, $DienThoai, $Quyen, $id){
		$sql = "UPDATE user
				SET TenUser = '$TenUser', MatKhau = '$MatKhau', DienThoai = '$DienThoai', Quyen = '$Quyen'
				WHERE MaUser = '$id'";
		$this->query_db($sql);
	}
}
?>